package servlet;

import java.io.IOException;
import java.util.List;

import javax.ejb.EJB;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bean.remote.SolicitudArticuloRemote;
import dominio.SolicitudArticulo;

/**
 * Busca todas las solicitudes de articulos y las muestra
 * @author Maxi.Herrera
 *
 */
public class SolicitudesArticuloServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1573707374472959571L;

	@EJB(beanName = "solicitudArticuloBean")
	private SolicitudArticuloRemote solicitudArticuloRemote;
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		List<SolicitudArticulo> solicitudArticulos = solicitudArticuloRemote.findAll();
		
		String page = "solicitudesArticulo.jsp";

		req.setAttribute("data", solicitudArticulos);
		
		// Disptching request
		RequestDispatcher dispatcher = req.getRequestDispatcher(page);

		if (dispatcher != null) {
			dispatcher.forward(req, resp);
		}
	}
}
